<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>

    <!-- Meta -->
    <meta name="description" content="Premium Quality and Responsive UI for Dashboard."/>
    <meta name="author" content="ThemePixels"/>

    <link rel="shortcut icon" th:href="@{/picture/favicon.ico}" type="image/x-icon"/>
    <title>茅台·天津 | 会员管理系统</title>

    <!-- vendor css -->
    <link th:href="@{/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/css/ionicons.css}" rel="stylesheet"/>
    <link th:href="@{/css/perfect-scrollbar.css}" rel="stylesheet"/>
    <link th:href="@{/css/github.css}" rel="stylesheet"/>
    <link th:href="@{/css/jquery.datatables.css}" rel="stylesheet"/>
    <link th:href="@{/css/select2.min.css}" rel="stylesheet"/>

    <!-- Starlight CSS -->
    <link rel="stylesheet" th:href="@{/css/starlight.css}"/>

</head>

<body>

<!-- ########## START: LEFT PANEL ########## -->
<div class="sl-logo">
    <a href="">
        <img th:src="@{/picture/mt_logo_wh.jpg}" style="width: 30px; height: 30px;"/>
        <span style="font-size: 18px">会员管理系统</span>
    </a>
</div>
<div class="sl-sideleft">

    <label class="sidebar-label">导航栏</label>
    <div class="sl-sideleft-menu">
        <a href="#" class="sl-menu-link active show-sub">
            <div class="sl-menu-item">
                <i class="menu-item-icon icon ion-ios-paper-outline tx-20"></i>
                <span class="menu-item-label">客户管理</span>
                <i class="menu-item-arrow fa fa-angle-down"></i>
            </div><!-- menu-item -->
        </a><!-- sl-menu-link -->
        <ul class="sl-menu-sub nav flex-column">
            <li class="nav-item"><a th:href="@{/customer/list}" class="nav-link">客户列表</a></li>
            <li class="nav-item"><a th:href="@{/customer/addCustomer}" class="nav-link">新增客户</a></li>
            <li class="nav-item"><a th:href="@{/company/list}" class="nav-link active">企业列表</a></li>
            <li class="nav-item"><a th:href="@{/customer/cusLevelList}" class="nav-link">客户等级列表</a></li>
        </ul>

        <a th:href="@{/about}" class="sl-menu-link">
            <div class="sl-menu-item">
                <i class="menu-item-icon icon ion-ios-bookmarks-outline tx-20"></i>
                <span class="menu-item-label">关于</span>
            </div><!-- menu-item -->
        </a><!-- sl-menu-link -->
    </div><!-- sl-sideleft-menu -->

</div><!-- sl-sideleft -->
<!-- ########## END: LEFT PANEL ########## -->

<!-- ########## START: HEAD PANEL ########## -->
<div class="sl-header">
    <div class="sl-header-left">
        <div class="navicon-left hidden-md-down"><a id="btnLeftMenu" href=""><i class="icon ion-navicon-round"></i></a>
        </div>
        <div class="navicon-left hidden-lg-up"><a id="btnLeftMenuMobile" href=""><i class="icon ion-navicon-round"></i></a>
        </div>
    </div><!-- sl-header-left -->
    <div class="sl-header-right">
        <nav class="nav">
            <div class="dropdown">
                <a href="" class="nav-link nav-link-profile" data-toggle="dropdown">
                    <span class="logged-name" th:text="${user.companyShortName} + ' | ' + ${user.name}">海津皇冠 | 皇冠</span>
                    <img th:src="@{/picture/moutai.png}" class="wd-32 rounded-circle" alt=""/>
                </a>
                <div class="dropdown-menu dropdown-menu-header wd-200">
                    <ul class="list-unstyled user-profile-nav">
                        <li><a href=""><i class="icon ion-ios-person-outline"></i> Edit Profile</a></li>
                        <li><a href=""><i class="icon ion-ios-gear-outline"></i> Settings</a></li>
                        <li><a href=""><i class="icon ion-ios-download-outline"></i> Downloads</a></li>
                        <li><a href=""><i class="icon ion-ios-star-outline"></i> Favorites</a></li>
                        <li><a href=""><i class="icon ion-ios-folder-outline"></i> Collections</a></li>
                        <li><a th:href="@{/logout}"><i class="icon ion-power"></i> Sign Out</a></li>
                    </ul>
                </div><!-- dropdown-menu -->
            </div><!-- dropdown -->
        </nav>
        <div class="navicon-right">
            <a id="btnRightMenu" href="" class="pos-relative">
                <i class="icon ion-ios-bell-outline"></i>
                <!-- start: if statement -->
                <span class="square-8 bg-danger"></span>
                <!-- end: if statement -->
            </a>
        </div><!-- navicon-right -->
    </div><!-- sl-header-right -->
</div><!-- sl-header -->
<!-- ########## END: HEAD PANEL ########## -->

<!-- ########## START: RIGHT PANEL ########## -->

<!-- ########## END: RIGHT PANEL ########## -->

<!-- ########## START: MAIN PANEL ########## -->
<div class="sl-mainpanel">
    <nav class="breadcrumb sl-breadcrumb">
        <!--<a class="breadcrumb-item" th:href="@{/activity/list}">茅台销售登记系统</a>-->
        <a class="breadcrumb-item" href="#">会员管理</a>
        <span class="breadcrumb-item active">企业列表</span>
    </nav>

    <div class="sl-pagebody">

        <div class="card pd-20 pd-sm-40">
            <h6 class="card-body-title">企业列表</h6>
            <p class="mg-b-20 mg-sm-b-15">The list of register company's information.</p>

            <div class="row tx-center mg-b-10">
                <div class="col-sm-3 col-lg-1">
                    <button type="button" class="btn btn-outline-primary btn-block">
                        导入
                    </button>
                </div><!-- col-3 -->
                <div class="col-sm-3 col-lg-1 mg-t-30 mg-sm-t-0">
                    <button type="button" class="btn btn-outline-primary btn-block">
                        导出
                    </button>
                </div><!-- col-3 -->
            </div><!-- row -->

            <div>
                <div class="table-responsive">

                    <!-- table start-->
                    <table id="datatable1" class="table display responsive nowrap">
                        <thead>
                        <tr>
                            <th class="wd-20p" style="text-align: center">企业名称</th>
                            <th class="wd-10p" style="text-align: center">企业积分</th>
                            <th class="wd-10p" style="text-align: center">索引记录</th>
                            <th class="wd-15p" style="text-align: center">创建时间</th>
                            <th class="wd-15p" style="text-align: center">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="com : ${list}">
                            <td th:text="${com.name}" style="text-align: center">Tiger</td>
                            <td th:text="${com.score}" style="text-align: center">Nixon</td>
                            <td th:if="${com.indexes != null &amp;&amp; com.indexes != ''}" th:text="${com.indexes}" style="text-align: center">
                                System Architect
                            </td>
                            <td th:if="${com.indexes == ''}" th:text="---------" style="text-align: center">System Architect</td>
                            <td th:text="${#dates.format(com.createTime,'yyyy-MM-dd HH:mm')}" style="text-align: center">2011/04/25</td>
                            <td style="text-align: center">
                                <input type="hidden" class="comId" th:value="${com.id}"/>
                                <a class="bt_details mg-r-10" data-toggle="modal" href="#showComDet">查看</a>
                                <a href="#" class="bt_update mg-r-10">编辑</a>
                                <a href="#" class="bt_del" data-toggle="modal" data-target="#confirmModal">删除</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div><!-- table-wrapper -->
            </div><!-- table-responsive -->

            <div class="modal fade" id="showComDet" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content" id="modalContent">

                    </div>
                </div>
            </div>

            <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content" id="modalContent1">
                        <div class="modal-header">
                            <h5 class="modal-title tx-14 mg-b-0 tx-uppercase tx-inverse tx-bold" id="modalLabel">删除信息</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        </div>
                        <div class="modal-body">
                            <span class="mg-r-30">确定要删除该条记录？</span><br/>
                            <span style="color: red;display:inline-block;width:200px;text-align:center;" id="msg_del"></span>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-info pd-x-20" id="bt_confirm">确  定</button>
                            <button type="button" class="btn btn-secondary pd-x-20" data-dismiss="modal">取  消</button>
                        </div>
                    </div>
                </div>
            </div>

        </div><!-- card -->
    </div><!-- sl-pagebody -->

    <footer class="sl-footer">
        <div class="footer-left">
            <div class="mg-b-2">Copyright &copy; 2018. 天津海津皇冠贸易有限公司. All Rights Reserved.</div>
        </div>
        <div class="footer-right d-flex align-items-center">Made by 海津皇冠.</div>
    </footer>

</div><!-- sl-mainpanel -->
<!-- ########## END: MAIN PANEL ########## -->


<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/js/popper.js}"></script>
<script th:src="@{/js/bootstrap.js}"></script>
<script th:src="@{/js/perfect-scrollbar.jquery.js}"></script>
<script th:src="@{/js/highlight.pack.js}"></script>
<script th:src="@{/js/jquery.datatables.js}"></script>
<script th:src="@{/js/datatables.responsive.js}"></script>
<script th:src="@{/js/select2.min.js}"></script>
<script th:src="@{/js/starlight.js}"></script>
<script th:src="@{/custom/company-list.js}"></script>

<script type="text/javascript">
    // <![CDATA[

    $(function () {
        'use strict';

        $('#datatable1').DataTable({
            responsive: true,
            language: {
                searchPlaceholder: '搜索...',
                sSearch: '',
                lengthMenu: '_MENU_ 条/页',
            }
        });

        // Select2
        $('.dataTables_length select').select2({minimumResultsForSearch: Infinity});
    });

    $(".bt_del").click(function () {
        var id = $(this).prev().prev().val();
        $("#bt_confirm").click(function () {
            $.ajax({
                type: "post",
                url: "/crm/customer/deleteCusLevel",
                data: {
                    "id": id
                },
                success: function (data) {
                    if (data == "SUCCESS") {
                        $("#msg_del").css({color: "green"});
                        $("#msg_del").html("删除成功！");
                        window.setTimeout(function () {
                            $(location).attr('href', '/crm/customer/cusLevelList');
                        }, 2000);
                    } else {
                        $("#msg_del").css({color: "red"})
                        $("#msg_del").html("删除失败！");
                        window.setTimeout(function () {
                            $(location).attr('href', '/crm/customer/cusLevelList');
                        }, 1200);
                    }
                }
            })
        })
    });

    $(".bt_details").click(function () {
        var id = $(this).prev().val();
        $.ajax({
            type: "POST",
            url: "/crm/company/" + id,
            success: function (data) {
                for (var key in data) {
                    if (data.hasOwnProperty(key) === true) {
                        if (data[key] == null || data[key] == "") {
                            data[key] = "------";
                        }
                    }
                }
                if (data.nature == '0') {
                    data.nature = "私企";
                } else if (data.nature == '1') {
                    data.nature = "国企";
                } else {
                    data.nature = "------";
                }

                var content = "<div class=\"modal-header\">\n" +
                    "<h5 class=\"modal-title tx-14 mg-b-0 tx-uppercase tx-inverse tx-bold\" id=\"modalLabel\">企业详细信息</h5>\n" +
                    "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n" +
                    "</div>";

                content += "<div class=\"modal-body\">\n" +
                    "<div class=\"card pd-10 pd-sm-20\">\n" +
                    "          <h6 class=\"card-body-title\">企业信息</h6>\n" +
                    "          <div class=\"progress mg-b-20\">\n" +
                    "                <div class=\"progress-bar ht-2 wd-100p\" role=\"progressbar\" aria-valuenow=\"100\"\n" +
                    "                     aria-valuemin=\"0\" aria-valuemax=\"100\"></div>\n" +
                    "          </div>" +
                    "          <dl class=\"row\">" +
                    "            <dt class=\"col-sm-2 tx-inverse\">企业名称</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.name + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">记录索引</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.indexes + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">企业积分</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.score + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">电子邮箱</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.email +"</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">地&nbsp;&nbsp;址</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.address + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">网&nbsp;&nbsp;址</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.net + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">注册资金</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.regCap + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">企业性质</dt>" +
                    "            <dd class=\"col-sm-4\">" +
                    "              <p class='mg-b-10'>" + data.nature + "</p>" +
                    "            </dd>" +
                    "            <dt class=\"col-sm-2 tx-inverse\">企业需求</dt>\n" +
                    "            <dd class=\"col-sm-10\">\n" +
                    "              <p class='mg-b-10'>" + data.need + "</p>\n" +
                    "            </dd>\n" +
                    "            <dt class=\"col-sm-2 tx-inverse\">备&nbsp;&nbsp;注</dt>\n" +
                    "            <dd class=\"col-sm-10\">\n" +
                    "              <p class='mg-b-10'>" + data.remarks + "</p>\n" +
                    "            </dd>\n" +
                    "            <dt class=\"col-sm-2 tx-inverse\">创建时间</dt>\n" +
                    "            <dd class=\"col-sm-4\">\n" +
                    "              <p class='mg-b-10'>" + data.createTime + "</p>\n" +
                    "            </dd>\n" +
                    "            <dt class=\"col-sm-2 tx-inverse\">创建人</dt>\n" +
                    "            <dd class=\"col-sm-4\">\n" +
                    "              <p class='mg-b-10'>" + data.createName + "</p>\n" +
                    "            </dd>\n" +
                    "        </div></div>";

                content += "<div class=\"modal-footer\">\n" +
                    "<button type=\"button\" class=\"btn btn-info pd-x-20\">编  辑</button>\n" +
                    "<button type=\"button\" class=\"btn btn-secondary pd-x-20\" data-dismiss='modal'>关  闭</button>\n" +
                    "</div>";

                $("#modalContent").html(content);

            }
        });
    });


    // ]]>
</script>

</body>
</html>
